﻿@{
    Layout = "~/Views/Shared/_Layout.cshtml";
    HQPad.Models.CharacterHeader header = (HQPad.Models.CharacterHeader) ViewBag.Header;
    List<HQPad.Models.RecordItem> record = (List<HQPad.Models.RecordItem>)ViewBag.Record;
    string name = (string)ViewBag.CharacterName;
}

<script src="@Url.Content("~/Scripts/waiter.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/messagelist.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/global.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/character.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $('body').character({
            raceChangeActionUrl: '@Url.Action("SetRace")',
            classChangeActionUrl: '@Url.Action("SetClass")',
            headerContainerSelector: '.header-container',
            tableChangeCallback: null,
            guildChangeActionUrl: '@Url.Action("SetGuild")',
            guildChangeCallback: null,
            recordContainerSelector: '.record-container',
            addRecordItemUrl: '@Url.Action("AddRecord")',
            addRecordCallback: function () {
                bindModals();
            },
            headerUrl: '@Url.Action("RefreshHeader")',
            headerRefreshedCallback: function () {
                $('.header-container .tooltipable[title]').tooltip();
            },
            recordsUrl: '@Url.Action("RefreshRecord")',
            recordsRefreshedCallback: function () {
                bindModals();
            }
        });

        bindModals();

        $('.tooltipable[title]').tooltip();
        
        setupMessageList(); // defined in global.
    });

    function bindModals() {
        // set up modal window links.
        $('.record-container .modal-window').nyroModal({
            sizes: { minW: 300, initH: 250, minH: 300, h: 250 },
            callbacks: {
               afterShowCont: function(nm) {
                    $('.nyroModalCont').addClass('record-modal');
				    //nm.store.iframe.attr('src', nm.opener.attr('href'));
			    } 
            }
        });
    }

    function closeModalAndRefresh() {
        $.nmTop().close();

        $('body').character('refreshHeader');
        $('body').character('refreshRecords');
        $('.tooltipable[title]').tooltip();
    }
</script>

<h1 class="with-control-box">@Html.Raw(name)</h1>
<div class="message-box"></div>

<section class="full-width header-container">
@Html.Partial("~/Views/Shared/Character/CharacterHeader.cshtml", header)
</section>

@Html.Partial("~/Views/Shared/Character/CharacterTabs.cshtml", header)

<section class="content flush-with-nav flat-top record-container">
@Html.Partial("~/Views/Shared/Character/CharacterRecord.cshtml", record)
</section>
